app.controller('pictureUpload', ['$scope','$modalInstance', function($scope,$modalInstance) {
    $scope.myImage='';
    $scope.myCroppedImage='';
    $scope.cropType="square";

    $scope.handleFileSelect = function(evt) {
      var file=evt.currentTarget.files[0];
      var reader = new FileReader();
      reader.onload = function (evt) {
        $scope.$apply(function($scope){
          $scope.myImage=evt.target.result;
        });
      };
      reader.readAsDataURL(file);
    };
    $scope.ok = function () {
        if($scope.myImage!="") {
            requestServlet("pictureUpload", {pictureFile: $scope.myCroppedImage.substring($scope.myCroppedImage.indexOf('base64,') + 7, $scope.myCroppedImage.length)}, function (rs) {
                $modalInstance.close(true);
            }, function (msg) {
            });
        }
    };
    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    };
}]);